﻿using CaltechSoft.Service.EntityFW.Repository;
using CaltechSoft.Service.Infrastructure;
using CaltechSoft.Service.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CaltechSoft.Service.ReportService.WorkOrder
{
    public class WorkOrderReportService : IWorkOrderReportService
    {
        private readonly ICommandExecutor _commandExecutor;

        private readonly IGenericRepository<EntityFW.Entity.WorkOrder> _workOrderGenericRepository;

        public WorkOrderReportService(ICommandExecutor commandExecutor, IGenericRepository<EntityFW.Entity.WorkOrder> workOrderGenericRepository)
        {
            _commandExecutor = commandExecutor;
            _workOrderGenericRepository = workOrderGenericRepository;
        }

        public SearchResult<WorkOrderDTO> Search(SearchCriteria.WorkOrderSearchCriteria searchCriteria, int pageSize, int pageIndex)
        {
            return _commandExecutor.Execute(new GetWorkOrderDTODbCommand(searchCriteria, pageSize, pageIndex));
        }

        public EntityFW.Entity.WorkOrder SearchById(int id)
        {
            var result = _workOrderGenericRepository.GetByID(id);

            return result;
        }
    }
}
